package com.jjc.android.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.jjc.android.R
import com.jjc.android.activity.VideoPlayerActivity
import com.jjc.android.entity.OperationVideoDto
import com.jjc.android.entity.VideoDto
import com.jjc.android.util.showImage

class OperationVideoAdapter : BaseQuickAdapter<OperationVideoDto,BaseViewHolder>(R.layout.item_operation_video) {

    init {
        setOnItemClickListener { _, _, position ->
            getItem(position)?.let {item->
                VideoPlayerActivity.start(mContext, VideoDto().apply {
                    video = item.b2fpmprchh9sgoaa.let { if(it.isNullOrEmpty()) null else it[0] }?.url
                    name = item.ufwm5h3hjvu3f0bq
                    time = item.createdAt
                })
            }
        }
    }

    override fun convert(helper: BaseViewHolder, item: OperationVideoDto) {
        helper.showImage(R.id.newsImage,item.b2fpmprchh9sgoaa.let { if(it.isNullOrEmpty()) null else it[0] }?.url)
        helper.setText(R.id.newsTitleText,item.ufwm5h3hjvu3f0bq)
        helper.setText(R.id.newsTimeText,String.format("%s %s",item.createdAt,mContext.getString(R.string.publish_txt)))
    }

}